home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-03-17 | 3.3 KB | 131 lines | [TEXT/CWIE] |
- //
- // CVehicleViewPane.h
- //
- // The view from the vehicle (a camera and lights) into a QD3D world.
- //
- // By James Jennings
- // Started July 9 1996
- //
-
- #pragma once
-
- #include "CQD3DPane.h"
- #include "CVehicle.h"
- #include "CObjectMaker.h"
-
- const CommandT cmd_ViewFromFront = 3001;
- const CommandT cmd_ViewFromBack = 3002;
- const CommandT cmd_ViewFromLeft = 3003;
- const CommandT cmd_ViewFromRight = 3004;
- const CommandT cmd_ViewFromTop = 3005;
- const CommandT cmd_ViewFromBottom = 3006;
- const CommandT cmd_ViewFromCenter = 3007;
- const CommandT cmd_LookAtCenter = 3008;
- const CommandT cmd_StabilizeRoll = 3010;
-
- const CommandT cmd_BackgroundColor = 1000;
-
- // helper function (no longer used?)
- //Boolean KeyIsDown( Char16 inKeyCode );
-
- class CAbstractLight : public CObjectMaker<TQ3LightObject> {
- public:
- Boolean IsOn()
- {
- TQ3Status theStatus;
- TQ3Boolean isOn;
- theStatus = ::Q3Light_GetState(Get(), &isOn);
- Assert_(theStatus==kQ3Success);
- return isOn == kQ3True;
- }
- void TurnOn(Boolean inOn)
- {
- TQ3Status theStatus;
- theStatus = ::Q3Light_SetState(Get(), (TQ3Boolean)inOn);
- Assert_(theStatus==kQ3Success);
- }
- };
-
- class CAmbientLight : public CAbstractLight {
- protected:
- virtual void Make()
- {
- TQ3LightData data = {
- kQ3False, // isOn
- 0.2, // brightness
- {1,1,1} // color
- };
- mObject = ::Q3AmbientLight_New(&data);
- Assert_(mObject != nil);
- }
- };
-
- class CFillLight : public CAbstractLight {
- protected:
- virtual void Make()
- {
- TQ3DirectionalLightData data = {
- {
- kQ3False, // isOn
- 0.75, // brightness
- {1,1,1} // color
- },
- kQ3False, // casts shadows
- {.5,-.5,-.7} // direction
- };
- ::Q3Vector3D_Normalize( &data.direction, &data.direction );
- mObject = ::Q3DirectionalLight_New(&data);
- Assert_(mObject != nil);
- }
- };
-
- class CVehicleViewPane : public CQD3DPane, public LPeriodical, public LCommander {
- public:
- enum { class_ID = 'VehV' };
- static CVehicleViewPane * CreateFromStream( LStream *inStream );
- static void Register()
- { URegistrar::RegisterClass(class_ID, (ClassCreatorFunc) CreateFromStream); }
-
- CVehicleViewPane( LStream *inStream );
-
- virtual void SetModel( TQ3GroupObject inGroup );
- virtual void SetCamera( TQ3CameraObject inCamera );
- virtual void SetLights( TQ3GroupObject inGroup );
- virtual TQ3CameraObject GetCamera(void);
- virtual TQ3GroupObject GetLights(void);
-
- virtual CVehicle * GetVehicle() { return &mVehicle; }
-
- // Commander methods
- virtual Boolean ObeyCommand(
- CommandT inCommand,
- void *ioParam = nil);
- virtual void FindCommandStatus(
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName);
- virtual void DoBackgroundColor();
-
- protected:
- virtual void ClickSelf(const SMouseDownEvent &inMouseDown);
- virtual void SpendTime( const EventRecord &inMacEvent );
- virtual void AdjustCursorSelf( Point inPortPt, const EventRecord& inMacEvent );
-
- virtual Boolean CheckAccelerationKeys( Boolean inDraw );
-
- virtual TQ3InterpolationStyle GetInterpolationStyle()
- { return kQ3InterpolationStyleVertex; }
- virtual TQ3BackfacingStyle GetBackfacingStyle()
- { return kQ3BackfacingStyleFlip; }
-
- CFillLight mExtraLight;
- CAmbientLight mExtraLight2;
-
- CVehicle mVehicle;
- TQ3Point3D mCenter;
- float mSceneRadius;
- Int32 mLastTime;
- };
-